<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background-color: pink;
        }
        .active {
            color:red;
            background-color: yellow;
        }
    </style>
</head>
<body>
    <div class="box">我是一个盒子</div>
    <script>
        // 元素.classList.add('新类名')
        const box = document.querySelector('.box')
        box.classList.add('active')
        // 元素.classList.remove('新类名')
        box.classList.remove('box')
        box.classList.toggle('box')


    </script>
</body>
</html>